package designpatterns.composite;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

/**
 * @author LiDong
 * @version 1.0.0
 * @createTime 2022/2/13 10:38
 */
@Slf4j
public class AppTest {

    public static final int SAL = 30000;
    public static final int SAL1 = 20000;
    public static final int SAL2 = 10000;
    public static final String ROBERT = "Robert";
    public static final String MARKETING = "Marketing";
    public static final String SALES = "Sales";

    @Test
    public void test() {
        Employee ceo = new Employee("John", "CEO", SAL);

        Employee headSales = new Employee(ROBERT, "Head Sales", SAL1);

        Employee headMarketing = new Employee("Michel", "Head Marketing", SAL1);

        Employee clerk1 = new Employee(designpatterns.filter.AppTest.LAURA, MARKETING, SAL2);
        Employee clerk2 = new Employee("Bob", MARKETING, SAL2);

        Employee salesExecutive1 = new Employee("Richard", SALES, SAL2);
        Employee salesExecutive2 = new Employee("Rob", SALES, SAL2);

        ceo.add(headSales);
        ceo.add(headMarketing);

        headSales.add(salesExecutive1);
        headSales.add(salesExecutive2);

        headMarketing.add(clerk1);
        headMarketing.add(clerk2);

        //打印该组织的所有员工
        log.info(ceo.toString());
        for (Employee headEmployee : ceo.getSubordinates()) {
            log.info(headEmployee.toString());
            for (Employee employee : headEmployee.getSubordinates()) {
                log.info(employee.toString());
            }
        }
    }

}
